<script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
<div class="layui-form-item" style="border: 1px solid #C0C4CC;margin: 8px 6px 4px 6px;padding-top: 2px">
    <textarea class="windowName" style="display: none;">${windowName}</textarea>
    <label class="layui-form-label">人员脚本：</label>
    <div class="layui-input-block">
        <input type="hidden" name="index">
        <input type="hidden" name="classInsName">
        <input type="hidden" name="methodName">
        <input type="hidden" name="condScriptId">
        <input type="text" name="condScriptName" id="condScriptName" required  lay-verify="required" disabled="disabled" autocomplete="off" class="layui-input" style="float: left;width: 150px">
        <a class="layui-btn" id="choosePersonScript">选择</a>
    </div>
</div>

<div class="layui-table-person-script">
    <table id="demo" lay-filter="test"></table>
</div>

</div><div id="windowUrls2" style="display: none"></div>
<script>
    //Demo
    layui.use(['layer', 'form', 'element','table','setter'], function(){
        var setter=layui.setter
            ,layer = layui.layer
            , form = layui.form
            , element = layui.element
            , table = layui.table
            ,$=layui.$;

        var index = layer.index;
        //人员脚本选择弹窗
        $('#windowUrls2').load("${ctx}/workflow/bpmNodeUser/view/choosePersonScript",{},function(response,status,xhr){
            $('#choosePersonScript').click(function () {
                layer.open({
                    title: '脚本选择',
                    type: 1,
                    shade: 0.3,
                    area: ['905px', '510px'],
                    content: $('#windowUrls2').html(),
                    zIndex: layer.zIndex,
                    success: function(layero, index){
                        $("input[name=index]").val(index);
                    }
                });
            });
        });

        //select发生改变,第二个select及input是否隐藏
        form.render("select");
        form.on('select(ctSelect)', function(data){
            //获取参数值类型
            var selDom = data.elem;
            var selVal = data.value;
            var typeDom = data.othis;
            //根据类型判断是否隐藏
            if(selVal==1){
                //select显示，input隐藏
                typeDom.nextAll("[name='paraCtType']").addClass("paraCtType");
                typeDom.nextAll('.layui-unselect').attr("style","display:black");
                typeDom.nextAll('.layui-input').attr("type","hidden");
            }else {
                //select隐藏，input显示
                typeDom.nextAll("[name='paraCtType']").removeClass('paraCtType');
                typeDom.nextAll('.layui-unselect').attr("style", "display:none");
                typeDom.nextAll('.layui-input').attr("type","text");
            }
        });

        //保存弹窗
        function savePersonScript(){
            //获取select参数值
            $('.layui-table .paraCtType').each(function(){
                var _val = $(this).val();
                if(_val!=0) {
                    hiddenJson  += (_val + ',');
                    showTxt     += (_val + ';');
                }
            });
            //获取input参数值
            $('.layui-table #paraCtType').each(function(){
                var _this = $(this);
                if(_this.attr("type")!='hidden'){
                    hiddenJson += (_this.val()+',');
                    showTxt    += (_this.val()+';');
                }
            });
            //对前弹窗文本域赋值
            if(showTxt.length>0) {
                hiddenJson = hiddenJson.substring(0, hiddenJson.lastIndexOf(',')) + ')';
                showTxt = showTxt.substring(0, showTxt.lastIndexOf(';')) + ')';
            }
            $(".hiddenJson").html(hiddenJson);
            $(".textarea").html(showTxt);


            // 关闭弹窗

            layer.close(index);
            return false;
        };
    });
</script>
<style>
    .layui-table-person-script .layui-table-cell {
        height: auto;
        overflow:visible;
    }
</style>